@*
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*@
@import kafka.manager.model.ActorModel.BrokerIdentity
@import scalaz.{\/}
@(cluster:String, errorOrBrokers: kafka.manager.ApiError \/ kafka.manager.BrokerListExtended
)(implicit af: features.ApplicationFeatures, messages: play.api.i18n.Messages, menus: models.navigation.Menus)

@theMenu = {
    @views.html.navigation.clusterMenu(cluster,"Brokers","",menus.clusterMenus(cluster)(
        errorOrBrokers.toOption.map(_.clusterContext.clusterFeatures).getOrElse(kafka.manager.features.ClusterFeatures.default)))

}
        
@renderBrokerMetrics(bl: kafka.manager.BrokerListExtended) = {
    @if(bl.clusterContext.clusterFeatures.features(kafka.manager.features.KMJMXMetricsFeature)) {
        @views.html.common.brokerMetrics(bl.combinedMetric)
    } else {
        <div class="alert alert-info" role="alert">
            Please enable JMX polling <a href="@routes.Cluster.updateCluster(cluster)" class="alert-link">here</a>.
        </div>
    }
}

@main(
    "Broker List",
    menu = theMenu,
    breadcrumbs=views.html.navigation.breadCrumbs(models.navigation.BreadCrumbs.withViewAndCluster("Brokers",cluster))) {
    <div class="col-md-7 un-pad-me">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3>
                    <button type="button" class="btn btn-link" onclick="goBack()">
                        <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span>
                    </button>Brokers
                </h3>
            </div>
            @errorOrBrokers.fold( views.html.errors.onApiError(_), views.html.broker.brokerListContent(cluster,_) )
        </div>
    </div>
    <div class="col-md-5 un-pad-me">
        <div class="panel panel-default">
            <div class="panel-heading"><h3>Combined Metrics</h3></div>
            @errorOrBrokers.fold( views.html.errors.onApiError(_), bl => renderBrokerMetrics(bl))
        </div>
    </div>

}
